package meijuli.com.join51.business.app

import android.app.Application
import android.content.pm.PackageManager
import com.tencent.tinker.loader.TinkerLoader
import com.tencent.tinker.loader.app.TinkerApplication
import com.tencent.tinker.loader.shareutil.ShareConstants
import com.umeng.socialize.PlatformConfig

/**
 * 聚惠侠应用实例
 *
 * @author Wizong 2017-05-19 13:09
 */
class MApplication : TinkerApplication(ShareConstants.TINKER_ENABLE_ALL,
                                        HotFixApplicationLike::class.java.name,
                                        TinkerLoader::class.java.name, false)  {

    override fun onCreate() {
        super.onCreate()
        instance = this
    }

    companion object {
        private var instance: Application? = null

        init {
            PlatformConfig.setWeixin("wxd4e33aef37d8a4f9", "52073fc51bd76b8d428a9e0d2c39e0b6")
            PlatformConfig.setQQZone("1106404559", "oxagh2t92g5kzpFQ")
            PlatformConfig.setSinaWeibo("2826050078", "ae83ba906ad7ffa703a53323cafb2ee9",
                    "http://sns.whalecloud.com")
        }

        fun get(): Application? {
            return instance
        }

        //获取软件版本号，对应AndroidManifest.xml下android:versionCode
        val version: String
            get() {
                var versionName = ""
                try {
                    versionName = instance!!.packageManager.getPackageInfo(instance!!.packageName, 0).versionName
                } catch (e: PackageManager.NameNotFoundException) {
                    e.printStackTrace()
                }

                return versionName
            }
    }

}
